import { createSSRApp } from "vue";
import App from "./App.vue";

// 引入pinia
import { createPinia } from 'pinia';

//引入封装http请求
import api from './api';

// 引入公共方法
import { Toast, trim } from '@/tools/util';

// 引入路由方法
import { router } from '@/tools/router';

// 引入storage
import { storage } from '@/tools/storage';

// 引入加密库
import encrypt from '@/tools/encrypt';

const app = createSSRApp(App);

app.config.globalProperties.$api = api;
app.config.globalProperties.$toast = Toast;
app.config.globalProperties.$router = router;
app.config.globalProperties.$storage = storage;
app.config.globalProperties.$encrypt = encrypt;
app.provide('$api', api);
app.provide('$toast', Toast);
app.provide('$router', router);
app.provide('$storage', storage);
app.provide('$encrypt', encrypt);

app.use(createPinia());

export function createApp() {
	return {
		app,
	};
}
